<?php

namespace App\Models;

use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Contracts\Auth\Authenticatable;

class User extends BaseModel implements JWTSubject, Authenticatable
{
    protected $table = 'users';
    
    /**
     * 性别：未知
     */
    const GENDER_UNKNOWN = 0;
    
    /**
     * 性别：男
     */
    const GENDER_MALE = 1;
    
    /**
     * 性别：女
     */
    const GENDER_FEMALE = 2;

    /**
     * 获取表字段
     * @return array
     */
    protected function columns(): array
    {
        return [
            'id',
            'openid',
            'nickname',
            'avatar',
            'gender',
            'country',
            'province',
            'city',
            'phone',
            'created_at',
            'updated_at',
            'deleted_at'
        ];
    }

    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    public function getJWTCustomClaims(): array
    {
        return ['id', 'nickname', 'avatar'];
    }


    public function getAuthIdentifierName()
    {
        return 'id';
    }

    public function getAuthIdentifier()
    {
        return $this->id;
    }

    public function getAuthPassword()
    {
        return $this->password;
    }

    public function getRememberToken()
    {
        return $this->{$this->getRememberTokenName()};
    }

    public function setRememberToken($value)
    {
        $this->{$this->getRememberTokenName()} = $value;
    }

    public function getRememberTokenName()
    {
        return '';
    }
}
